﻿using System;
using WebFormsMvp.Contrib.Models;

namespace WebFormsMvp.Contrib.Presenters
{
    /// <summary>
    /// 
    /// </summary>
    public class GoogleAnalyticsPresenter : Presenter<IView<GoogleAnalyticsModel>>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GoogleAnalyticsPresenter"/> class.
        /// </summary>
        /// <param name="view">The view.</param>
        public GoogleAnalyticsPresenter(IView<GoogleAnalyticsModel> view) : base(view)
        {
            view.Load += new EventHandler(View_Load);
        }

        /// <summary>
        /// Handles the Load event of the View control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public virtual void View_Load(object sender, EventArgs e)
        {
            this.View.Model.TrackingCode = "TrackingCode no set";
        }

        /// <summary>
        /// Releases the view.
        /// </summary>
        public override void ReleaseView()
        {
            this.View.Load -= new EventHandler(this.View_Load);
        }
    }
}
